/**
 * ClassName: test
 * Package: PACKAGE_NAME
 * Description:
 *
 * @Author 蒋林康
 * @Create 2023/12/25 13:44
 * @Version 1.0
 */
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileCopy {
    public static void copyFile(String srcPath, String destPath) {
        try {
            FileInputStream fis = new FileInputStream(srcPath);
            FileOutputStream fos = new FileOutputStream(destPath);

            byte[] buffer = new byte[1024];
            int length;
            while ((length = fis.read(buffer)) > 0) {
                fos.write(buffer, 0, length);
            }

            fis.close();
            fos.close();
            System.out.println("文件复制成功！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String srcPath = "C:\\Users\\lenovo\\Desktop\\python笔记\\a.txt"; // 原文件路径
        String destPath = "C:\\Users\\lenovo\\Desktop\\python笔记\\b.txt"; // 目标文件路径

        copyFile(srcPath, destPath);
    }
}

